package com.example.xw.common.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.xw.common.entity.Weibo;
import com.example.xw.common.service.fallback.FallbackWeiboServiceImpl;
import com.example.xw.common.vo.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value="xw-weibo",contextId="weiboService",fallback = FallbackWeiboServiceImpl.class)
public interface WeiboService {
        //添加微博
        @PostMapping("/weibo/add")
        public Result<Weibo> weiboAdd(
                @RequestParam("userloginname") String userloginname,@RequestParam("title")String title
                ,@RequestParam("content")String content,@RequestParam("img")String img);
        //根据id查询单条微博对象
        @RequestMapping("/weibo/findbyid")
        public Result<Weibo> findById(@RequestParam("id") int id);
        //根据用户名查询微博对象
        @RequestMapping("/weibo/findbyuser")
        public Result<Page<Weibo>> findByUserLoginName(
                @RequestParam("pagenum") int pageNum,@RequestParam("pagesize") int pageSize
                ,@RequestParam("userloginname") String userloginname,@RequestParam("state") int state
        );
        //查询所有微博
        @RequestMapping(" /weibo/list")
        public Result<Page<Weibo>> findList(
                @RequestParam("pagenum") int pageNum,@RequestParam("pagesize") int pageSize
                ,@RequestParam("findtxt") String findtxt,@RequestParam("state") int state);
        //修改阅读量
        @PostMapping(" /weibo/updateReadCount")
        public Result<Integer> updateReadCount(@RequestParam("wbid") int wbid);
        //管理员修改状态
        @PostMapping("/weibo/updateState")
        public Result<Weibo> updateState(
                @RequestParam("wbid") int wbid,@RequestParam("state") int state);
        //根据用户名查询微博总数
        @RequestMapping("/weibo/findcountbyuser")
        public Result<Integer> findCountByUserLoginName(
                @RequestParam("userloginname") String userloginname,
                @RequestParam("state") int state);
        //删除微博
        @PostMapping("/weibo/delete")
        Result<Boolean> delete(@RequestParam("id") int id);




}
